#!/bin/sh -vx
# $Id$
# Public domain. Originally written by Martin Ruckert
# Basic check that rule.tex can be hitexed, histretched, hishrinked.

LC_ALL=C; export LC_ALL;  LANGUAGE=C; export LANGUAGE

TEXMFCNF=$srcdir/../kpathsea; export TEXMFCNF
TEXINPUTS=$srcdir/hitexdir/tests; export TEXINPUTS
OUTDIR=./hitexdir/tests/outdir; mkdir $OUTDIR

./hitex -ini --interaction=nonstopmode -output-directory=$OUTDIR rule.tex \
|| exit $?
./histretch $OUTDIR/rule.hnt || exit $?
./hishrink -o $OUTDIR/rule.out.hnt $OUTDIR/rule.hint || exit $?
./histretch $OUTDIR/rule.out.hnt || exit $?

if grep "<rule 0x48.451Ept 1pt 0x1C.73E7pt>" $OUTDIR/rule.hint >/dev/null; then
  : # OK
else
  echo "rule.hint does not contain the proper <rule, goodbye." >&2
  exit 1
fi

if diff $OUTDIR/rule.out.hint $OUTDIR/rule.hint; then # -w?
  : # OK
else
  echo "rule.out.hint and rule.hint differ, goodbye." >&2
  exit 1
fi

exit 0
